First 23.5 Second 45.1
The contents of a variable can come from the result of a calculation. You can use a result to replace the contents of a variable. Look at the following program:
' Which earns the most money? ' 40 hours at $5 an hour, or ' 30 hours at $6 an hour ' LET RATE = 5 LET HOURS = 40 LET PAY = HOURS * RATE PRINT "Pay for ", HOURS, "hours at ", RATE, " = " , PAY ' LET RATE = 6 LET HOURS = 30 LET PAY = HOURS * RATE PRINT "Pay for ", HOURS, "hours at ", RATE, " = " , PAY ' END
Here is how the first half of the program works:
RATE
, and 5 is stored there.HOURS
, and 40 is stored there.PAY
.HOURS
.RATE
.PAY
.HOURS
, gets the 40, and writes it.RATE
, gets the 5, and writes it.=
.PAY
, gets 200, and writes it.At this point computer memory looks like:
|
|
|
What does the first half of the program print to the screen?